#!/usr/bin/perl 
#===============================================================================
#
#         FILE:  testparsepod.pl
#
#        USAGE:  ./testparsepod.pl 
#
#  DESCRIPTION:  
#
#      OPTIONS:  ---
# REQUIREMENTS:  ---
#         BUGS:  ---
#        NOTES:  ---
#       AUTHOR:  Beomsu Chang (bschang), <bschang@phya.yonsei.ac.kr>
#      COMPANY:  
#      VERSION:  1.0
#      CREATED:  2008년 03월 04일 20시 08분 32초 KST
#     REVISION:  ---
#===============================================================================

use strict;
use warnings;

use Pod::Parser;
package WebTranslate::PodParser;
use base qw(Pod::Parser);
use constant {
	    VERBATIM  => 1,
	    TEXTBLOCK => 2,
	    COMMAND   => 4,
};

sub verbatim {
    my ($self, $text, $line_num, $pod_para) = @_;
    $self->store_section(VERBATIM, $text);
}

sub textblock {
    my ($self, $text, $line_num, $pod_para) = @_;
    $self->store_section(TEXTBLOCK, $text);
}

sub command {
    my ($self, $cmd, $text, $line_num, $pod_para)  = @_;
	$self->{'wt_SecNum'}++;
	$self->{'wt_UnitNum'} = 0;
    $self->store_section(COMMAND, $pod_para->raw_text);
}

sub store_section {
    my ($self, $type, $content) = @_;

    # get rid of nuls so that we can use them safely in PodToHtml
    $content =~ s/\0//g; 
    return if ($content =~ /^\s*$/); # skip blank paragraphs
	
    ++$self->{'wt_UnitNum'};
	++$self->{'wt_Count'};
	$self->{'wt_data'}[$self->{'wt_Count'}] = {
		Sec 	=> $self->{'wt_SecNum'},
		Unit	=> $self->{'wt_UnitNum'},
		Content => $content,
	};
}

sub getWT_DATA {
	my $self = shift;
	return $self->{'wt_data'};
}

1;
